<template>
	<view>
		<u-gap height="36" bg-color="white"></u-gap>
		<view style="padding-left: 30rpx; padding-right: 30rpx;">
			<form @submit="loginSubmit" @reset="loginReset" >
				<view style="font-size: 72rpx; font-weight: 900;">加入</view>
				<u-gap height="16" bg-color="white"></u-gap>
				<view style="font-weight: 300;">不断云班BCC - 同学动态社交</view>
				<u-gap height="12" bg-color="white"></u-gap>
				<view style="font-weight: 300;">tip:内测期需通过邀请码注册，若无请<text style="color:#FCAB01" @click="res">申请体验资格</text></view>
				<u-gap height="16" bg-color="white"></u-gap>
				<input placeholder="请输入用户名(必填)" v-model="username" maxlength="20" confirm-type="next" class="login_input"/>
				<input placeholder="请输入昵称(必填)" v-model="nickname" maxlength="20" confirm-type="next" class="login_input"/>
				<input placeholder="请输入密码(必填)" v-model="password" password="true" maxlength="24" confirm-type="done" class="login_input"/>
				<input placeholder="请输入邮箱(必填)" v-model="email" maxlength="20" confirm-type="next" class="login_input"/>
				<input placeholder="请输入手机号码(必填)" v-model="phone" maxlength="20" confirm-type="next" class="login_input"/>
				<view style="float: right;display: inline;margin-left: 24rpx;">
					<u-button type="defult" class="u-m-t-40" style="background-color:#FCAB01;color: #fff;border-radius: 8px;">获取验证码</u-button>

				</view>
				<view style="display: inline;">
					<input placeholder="请输入验证码(必填)" v-model="checkcode" maxlength="6" confirm-type="next" class="login_input"/>
				</view>
				<input placeholder="请输入邀请码(选填)" v-model="invitecode" maxlength="20" confirm-type="next" class="login_input"/>
				<view style="font-size:21rpx">
					<u-checkbox
						active-color="#FCAB01"
						class="checkbox"
						v-model="limit" 
						:name="limit"
					></u-checkbox>
					是否同意<text style="color:#FCAB01">《不断同学账户使用准则》</text>及<text style="color:#FCAB01">《隐私条款》</text>
				</view>
				
				<u-gap height="12" bg-color="white"></u-gap>
				<u-button type="defult"  form-type="submit" :hair-line="false" class="u-m-t-30" style="background-color:#FCAB01;color: #fff;border-radius: 8px;" >加入云班</u-button>
			</form>
			<u-gap height="32" bg-color="white"></u-gap>
			<view>
				<text style="color: #FCAB01;" @click="backLogin">已有账户？返回登录</text>
			</view>
			<u-gap height="72" bg-color="white"></u-gap>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				limit:false
			}
		},
		onLoad() {
			
		},
		methods: {
			res(Info){
				uni.navigateTo({
					url:'../nokey/gettestaccount'
				})
			},
			backLogin(Info){
				uni.navigateTo({
					url:'login'
				})
			},
			loginSubmit(LogInfo){
				
				uni.request({
					url:'http://api.cc.ibuduan.com/test/reg.php',
					method:'GET',
					data: {
						'un':this.username,
						'pwd':this.password
					},
					dataType:'JSON',
					success:(res) => {
						if(res.data.err_code == '0'){
							uni.showModal({
								title:'用户有效',
								content:'未开放，uid：'+res.data.text.uid
							})
							
						}else if(res.data.err_code == 'CK02001'){
							uni.showModal({
								title:'登录失败',
								content:'用户名或密码错误 Code:CK02001'
							})
						}else if(res.data.err_code == 'CK02002'){
							uni.showModal({
								title:'登录失败',
								content:'无此用户 Code:CK02002'
							})
						}else{
							uni.showModal({
								title:'登录失败',
								content:'其他错误 Code:CK00000',
							})
						}
					},
					fail:uni.showModal({
						title:'请求失败',
						content:'网络错误或服务器处于维护状态 \n（作者服务器可能又挂了）'
					})
				})
			}
		}
	}
</script>

<style>
.login_input{
	margin-top: 30rpx;
	margin-buttom: 30rpx;
	background-color: #f6f6f6;
	height: 96rpx;
	padding-left: 8px;
	border-radius: 8px;
	
}
.checkbox{
	padding-top: 24rpx;
	color: #FCAB01;
	transform:scale(0.9)
}
</style>
